//
// Created by Ctzzz on 2024/4/26.
//

#ifndef NDKDEMO_GLUTILS_H
#define NDKDEMO_GLUTILS_H


#include <GLES3/gl3.h>

class GLUtils {
public:
    /**
     * 创建着色器
     * @param shaderType 着色器类型
     * @param pSource 着色器源
     * @return
     */
    static GLuint LoadShader(GLenum shaderType, const char *pSource);

    /**
     * 创建Program
     * @param pVertexShaderSource  顶点着色器源
     * @param pFragShaderSource  片元着色器源
     * @param vertexShaderHandle  顶点着色器句柄
     * @param fragShaderHandle  片元着色器句柄
     * @return
     */
    static GLuint CreateProgram(const char *pVertexShaderSource,
                              const char *pFragShaderSource,
                              GLuint &vertexShaderHandle,
                              GLuint &fragShaderHandle);

    /**
     * 删除Program
     * @param program
     */
    static void DeleteProgram(GLuint &program);

    /**
     * 检查GL错误
     * @param pGLOperation
     */
    static void CheckGLError(const char *pGLOperation);
};


#endif //NDKDEMO_GLUTILS_H
